package org.thanos.demo.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.thanos.demo.producer.DemoKafkaProducer;

import java.util.UUID;

@Component
public class StartupListener implements ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    private DemoKafkaProducer producer;

    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        producer.publish(UUID.randomUUID().toString());
    }
}
